//
//  ViewController2.m
//  scrollview2
//
//  Created by student on 16/2/29.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController2.h"

@interface ViewController2 ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollview;
@property(nonatomic,weak)UIImageView *imageview;

@end

@implementation ViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIImage *image=[UIImage imageNamed:@"123.jpg"];
    UIImageView *imageview=[[UIImageView alloc]initWithImage:image];
    imageview.tag=101;
    [self.scrollview addSubview:imageview];
    self.imageview=imageview;
    self.scrollview.contentSize=image.size;
    self.scrollview.maximumZoomScale=2;
    self.scrollview.minimumZoomScale=0.2;
    self.scrollview.delegate=self;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(nullable UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.imageview;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you 
 often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
